<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>KIT ADMIN</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/plugins/build/css/app.css" media="all">
</head>
<style>
    .bg-f2{
        background-color: #F2F2F2;
    }
    .docinfo{
        margin-left: 8px;
        display: block;
        float: right;
        color: #009688;
    }
    .docinfo i {
        font-size: 20px;
    }
    .docinfo:hover{
        color: #009688;
    }
    .layui-col-space15>*{
        padding: 3px;
    }
    .module-title{
        display: block;
        width: 100%;
        height: 24px;
        line-height: 24px;
        padding-bottom: 10px;
        margin-bottom: 10px;
        border-bottom: 1px solid #eee;
    }
    .module-title .layui-breadcrumb {
        visibility: visible;
    }
    .module-title .back i{
        font-size: 20px;
    }
    .module-title .back span{
        vertical-align: top;
        color: #888;
    }
    .module-title .back span:hover{
        color: #5FB878;
    }
    .module-info{
        margin: 0px;
    }
    .module-info .layui-card-body{
        height: 43px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .layui-card-header{
        color: #009688;
    }
    .download{
        top: 1px;
        position: relative;
    }
</style>
<body>
<div class="container">
    <divc class="module-title">
        <span class="layui-breadcrumb">
            <a href="javascript:history.go(-1);" class="back">
                <i class="layui-icon back">&#xe603;</i>
                <span class="moduleName"></span>
            </a>
        </span>
    </divc>
    <div class="layui-row layui-col-space15 module-info">

    </div>
</div>
<script src="/plugins/layui/layui.js"></script>
<script src="/plugins/common.js"></script>
<script>
    //所有子模块
    var listUrl = SERVER_URL+"/moduleInfo/moduleSubLevelList";

    layui.use(['jquery', 'table', 'form','layer'], function() {
        var $ = layui.jquery;
        layer.config({
            anim: 5
            ,offset: '50px'
            ,maxmin: true
            ,isOutAnim: false,
            shade: [0.5, '#eee']
        })

        //初始化模块信息
        function initModuleInfo(data) {
            if(data){
                $(".module-info").html("");
                var str = "";
                for(var i in data){
                    str += "<div class=\"layui-col-xs4 bg-f2\"><div class=\"layui-card\"><div class=\"layui-card-header\"><i class=\"layui-icon\" style='margin-right: 5px;'>&#xe653;</i>";
                    str += data[i].moduleName;
                    str += "<a class=\"docinfo download\" target=\"_blank\" href=\"doc.html?moduleCode="+data[i].moduleCode+"\"><i class=\"layui-icon\">&#xe6a2;</i></a>";
                    str += "<a class=\"docinfo\" href=\"javascript:view('"+data[i].moduleCode+"','"+data[i].moduleName+"')\"><i class=\"layui-icon\">&#xe63c;</i></a>";
                    str += "</div>";
                    str += "<div class=\"layui-card-body\">";
                    str += data[i].moduleDesc;
                    str += "</div></div></div>";
                }
                $(".module-info").append(str);
            }
        }

        //判断新增or修改
        if(urlParam("moduleCode") && urlParam("moduleName")){
            $(".moduleName").html("父级模块："+urlParam("moduleName"));
            layer.load(2, {time: 5*1000});
            $.ajax({
                type: 'GET',
                url: listUrl,
                data: {moduleCode: urlParam("moduleCode")},
                success: function (result) {
                    layer.closeAll();
                    if(result.code == 20000){
                        initModuleInfo(result.data);
                    }else{
                        layer.msg(result.msg, {time: 1500});
                    }
                }
            });
        }
    });

    //下载文档
    function download(moduleCode) {
        alert(moduleCode)
    }

    //查看文档
    function view(moduleCode, moduleName) {
        var info = layer.open({
            area: ['800px', '500px']
            ,type: 2
            ,title: moduleName
            ,content: "info.html?moduleCode="+moduleCode
        });
        layer.full(info);
    }

    //地址栏参数
    function urlParam(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)	return decodeURIComponent(r[2]);
        return null;
    }
</script>
</body>
</html>